import CommonHeader from '@/components/CommonHeader';
import CommonFooter from '@/components/CommonFooter';
import { Component, useEffect } from 'react';
import { IRouteComponentProps, useDispatch } from 'umi';
import { Layout } from 'antd';
const whiteList = ['/', '/archives', '/knowledges'];
export default function GlobalLayout({
  children,
  location,
  route,
  history,
  match,
}: IRouteComponentProps) {
  let body = children;
  if (whiteList.indexOf(location.pathname) !== -1) {
    body = <div className="container content">{children}</div>;
  }
  const dispatch = useDispatch();

  // 获取网站的全局配置
  useEffect(() => {
    dispatch({
      type: 'setting/getSetting',
    });
    dispatch({
      type: 'setting/getPageSetting',
    });
  }, []);
  return (
    <Layout>
      <CommonHeader />
      {body}
      <CommonFooter />
    </Layout>
  );
}
